package ogs.lib.mina.filter.codec
{
	import ogs.lib.mina.core.filterchain.NextFilter;
	
	public class ProtocolDecoderOutputImpl implements ProtocolDecoderOutput
	{
		private var messageQueue:Array = [];

		public function ProtocolDecoderOutputImpl()
		{
		}
		
		public function getMessageQueue():Array 
		{
			return messageQueue;
		}
		
		public function write(message:Object):void
		{
			if (message == null) {
				throw new ArgumentError("message");
			}
			
			messageQueue.push(message);
		}
		
		public function flush(nextFilter:NextFilter):void
		{
			var messageQueue:Array = getMessageQueue();
			
			while (messageQueue.length) {
				nextFilter.messageReceived(messageQueue.shift());
			}
		}
	}
}
